package com.chhuang.bean;

import com.chhuang.core.valid.ValidationGroups;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotBlank;
import java.util.Date;

/**
 * @ClassName CaptchaBean
 * @Description 验证码实体类
 * @Author Darren Huang
 * @Date 2022/11/20 19:02
 * @Version 1.0
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "CaptchaBean实体类", description = "验证码实体类")
public class CaptchaBean {
    public CaptchaBean(@NotBlank(message = "{captcha.not_blank}") String sessionId, long timeout, Date createTime) {
        this.sessionId = sessionId;
        this.timeout = timeout;
        this.createTime = createTime;
    }

    /**
     * 验证码
     */
    @NotBlank(message = "{captcha.not_blank}")
    @ApiModelProperty(value = "验证码，获取验证码时放验证码图片base64编码给前端，返回提交校验时放用户输入的验证码字符串", required = true)
    private String captcha;

    /**
     * 验证码保存在sa-token Custom Session中的id
     */
    @NotBlank(message = "{session.not_exist}")
    @ApiModelProperty(value = "验证码保存的sessionId，获取验证码时生成，返回给前端，前端提交校验时带回", required = true)
    private String sessionId;

    /**
     * 验证码过期时间（单位：秒）
     */
    @ApiModelProperty(value = "验证码过期时间（单位：秒）")
    private long timeout;

    /**
     * 创建时间
     */
    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;
}
